package com.alasbusy.alasbusyapp.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.alasbusy.alasbusyapp.R;
import com.alasbusy.alasbusyapp.base.BaseActivity;
import com.zhy.android.percent.support.PercentLinearLayout;

public class LoginActivity extends BaseActivity implements View.OnClickListener {

    private PercentLinearLayout regis_btn;
    private PercentLinearLayout login_btn;
    private TextView login_tishi;
    private EditText login_name;
    private EditText password;

    @Override
    protected void initView() {
        PercentLinearLayout login_title = findViewById(R.id.login_title);
        setTop(login_title);
        getVisibility(true,this);
        getTitle("登录");

        regis_btn = findViewById(R.id.regis_btn);
        login_btn = findViewById(R.id.login_btn);
        login_tishi = findViewById(R.id.login_tishi);
        login_name = findViewById(R.id.login_name);
        password = findViewById(R.id.password);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {
        login_btn.setOnClickListener(this);
        regis_btn.setOnClickListener(this);
        findViewById(R.id.wj_pwd_txt).setOnClickListener(this);
    }

    @Override
    public int getLayout() {
        return R.layout.activity_login;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.regis_btn:
                startActivity(new Intent(LoginActivity.this,RegisActivity.class));
                break;
            case R.id.login_btn:
                String name = login_name.getText().toString();
                String pwd = password.getText().toString();
                if(!TextUtils.isEmpty(name) || !TextUtils.isEmpty(pwd)) {
                    login_tishi.setVisibility(View.INVISIBLE);

                }else {
                    login_tishi.setVisibility(View.VISIBLE);
                    login_tishi.setText("账号或密码不能为空.");
                }
                break;
            case R.id.wj_pwd_txt:
                startActivity(new Intent(LoginActivity.this,UpdatePwdActivity.class));
                break;
        }
    }
}
